VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
END
Attribute VB_Name = "ODBC1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = True
'Project Name:  Array
'Host Name:     Array.ODBC1
'Date:          01/30/04
'Version:       1.31.00
'Revised by:    Don Stewart

'Writeback for Array/Coty batch to CSV.

'The following functions are used:
'Connect:           Establish connection to cust DSN
'QueryTable:        Queries cust DSN & populates CAFE screen
'ReleaseLocal:      Kills mod level objects
'ODBC_Insert:       Writeback Ref no & Tracking No.
'DeleteRecord:      Delete Records from csv or txt file.

'DSN:               None, CSV
'Output File:       Batch input file name + ".csv"
'


Option Explicit
'




Public Sub ODBC_Insert(ByVal strTrackingNumber As String)

    On Error GoTo ErrorExit
    
    Dim i As Long
    Dim objFSO As New FileSystemObject
    Dim tblShipmentLookUp As Table
    Dim intFile As Integer
    Dim strInsert As String
    Dim lngPieceNumber As Long
 
    With objFSO.OpenTextFile(OutputFileName, ForAppending, True)
        Set tblShipmentLookUp = Cafe2.Databases.ExecDirect("select 1123 from Shipment where 29 = '" & strTrackingNumber & "'")
        strTrackingNumber = tblShipmentLookUp.Records(0).Fields("1123").Value
        'Retrieve informatioon from the shipment database
        ' Set tblShipmentLookUp = cafe2.Databases.Shipment("21,37,112,116,498,1274,1273,24,68,23,70,25", , IsInternational).Lookup(TrackingNumber)
        Set tblShipmentLookUp = Cafe2.Databases.Shipment("29,3001,21,37,112,116,498,1274,1273,24,68,23,70,25", , True).Lookup(strTrackingNumber)
        'Setting the insert information
        strInsert = tblShipmentLookUp.Records(0).Fields("3001").Value & "," _
            & tblShipmentLookUp.Records(0).Fields("29").Value
        .WriteLine strInsert
        .Close
    End With

AllExit:
    Breathe
    Exit Sub

ErrorExit:
    'MsgBox "ODBC1.ODBC_Insert - " & Err.Source & " - " & Err.Description
    Resume AllExit
    Resume
End Sub
'


Friend Function DeleteRecord(ByVal strDeleteValue As String) As Boolean
    On Error GoTo ErrorExit
    
    Dim objFSO As New FileSystemObject
    Dim tblShipmentLookUp As Table
    Dim strInsert As String
    Dim intFile As Integer
    
    Set tblShipmentLookUp = Cafe2.Databases.Shipment("3001,498", , True).Lookup(strDeleteValue)
    'Setting the insert information
    strInsert = tblShipmentLookUp.Records(0).Fields("3001").Value _
        & "," & strDeleteValue _
        & "" & "," & "VOID"
        
    With objFSO.OpenTextFile(OutputFileName, ForAppending, True)
        .WriteLine strInsert
        .Close
    End With
        
AllExit:
    Exit Function

ErrorExit:
    'MsgBox "Error, " & Err.Source & ", " & Err.Description, vbApplicationModal + vbSystemModal
    Resume AllExit
    
End Function

Sub UpperValue(ByRef Name As String)

    Name = UCase(Name)
    
End Sub 'UpperValue







